package util;

import java.io.File;

public class PathManager {
	private static String basePath = "userPath/";
	private static String realPath = "";
	private static String webRootPath = "";
	
	public static String getClassRootPathByName(String college,String classname) {
		String path = basePath+"/"+college+"/"+classname;
		dirTest(path);
		return path;
	}
	public static String getClassMindArticlePathByName(String college,String classname,int id) {
		String path = basePath+"/"+college+"/"+classname+"/mind";
		dirTest(path);
		return path;
	}
	public static String getClassActivityArticlePathByName(String college,String classname,int id) {
		String path = basePath+"/"+college+"/"+classname+"/activity";
		dirTest(path);
		return path;
	}
	public static String getCollegeRootPathByName(String college) {
		String path = basePath+"/"+college;
		dirTest(path);
		return path;
	}
	public static String getCollegeArticlePathByName(String college,int id) {
		String path = basePath+"/"+college+"/article";
		dirTest(path);
		return path;
	}
	//****************************************************************************************
	public static String getCollegeRealHtmlPath(String college,int id) {
		String path = realPath+"/"+college+"/article/"+id;
		dirTest(path);
		return path;
	}
	public static String getCActivityRealHtmlPath(String college,String className,int id) {
		String path = realPath+"/"+college+"/"+className+"/activity/"+id;
		dirTest(path);
		return path;
	}
	public static String getCMindRealHtmlPath(String college,String className,int id) {
		String path =realPath+"/"+college+"/"+className+"/mind/"+id;
		dirTest(path);
		return path;
	}
	
	private static void dirTest(String path) {
		File check = new File(path);
        if (!check.exists()) check.mkdirs();
	}
	
	//*****************************************************************************************
	public static void setRealPath(String path) {
		realPath = path;
		dirTest(path);
	}
	public static void setWebRootPath(String path) {
		webRootPath = path;
	}
	public static String getParmPath() {
		return webRootPath+"/myConfigure/db.properties";
	}
	public static String getCssRealPath() {
		return realPath+"/aStyle.css";
	}
	public static String addCollegePath(String college) {
		realPath+="/"+college;
		 File check = new File(realPath);
        if (!check.exists()) check.mkdirs();
        File a = new File(realPath+"/"+"article");
  	   	if(!a.exists()) a.mkdirs();
  	   	return realPath;
	}
	public static String addClassPath(String college,String className) {
		 realPath+="/"+college+"/"+className;
		 File check = new File(realPath);
         if (!check.exists()) {
      	   check.mkdirs();
         }
         File a = new File(realPath+"/"+"activity");
         if(!a.exists()) a.mkdirs();
    	 File m = new File(realPath+"/"+"mind");
    	 if(!m.exists()) m.mkdirs();
    	 return realPath;
	}
	
}
